<include file="public:header" />
<include file="public:left" />
<div class="flexigrid">
    <div class="mDiv">
        <div class="ftitle">
            <h3>编辑</h3>
            <h5><a class="fr" href="javascript:void(0)" onclick="history.go(-1)">返回上一页</a></h5>
        </div>
    </div>
</div>
	<form  method="post" enctype="multipart/form-data" id="brandForm">
		<input type="hidden" name="aid" value="{$aid}" />
     <section>
      <ul class="ulColumn2">
          <li>
              <span class="item_name" style="width:120px;">区域：</span>
              <select id="s_province" name="province"></select>
              <select id="s_city" name="city" ></select>
              <select id="s_county" name="county"></select>
          </li>
          <div class="shop">
              <eq name="aid" value="1">
          <li class="addshop">
              <span class="item_name" style="width:120px;">推荐店铺：</span>
              <a href="javascript:;" id='add-param' onclick="addshop()" style="margin-top:10px;" class="btn btn-primary"  title="增加店铺"><i class='fa fa-plus'></i> 增加店铺</a>
              <table style="margin-left: 60px;margin-top: 10px;" cellspacing="100" >
                  <tbody id="param-items" >
                  </tbody>
              </table>
          </li>
              </eq>
              <eq name="aid" value="2">
                  <li class="addshop">
                      <span class="item_name" style="width:120px;">推荐菜品：</span>
                      <a href="javascript:;" id='add-param' onclick="addgoods()" style="margin-top:10px;" class="btn btn-primary"  title="增加菜品"><i class='fa fa-plus'></i> 增加菜品</a>
                      <table style="margin-left: 60px;margin-top: 10px;" cellspacing="100" >
                          <tbody id="param-items" >
                          </tbody>
                      </table>
                  </li>
              </eq>
          </div>

       <li>
        <span class="item_name" style="width:120px;"></span>
        <input type="button" class="link_btn" value="提交"/>
       </li>
      </ul>
     </section>
	 </form>

<script class="resources library" src="__STATIC__/admin/js/area.js" type="text/javascript"></script>
<script type="text/javascript">_init_area();</script>
<script>
    function addshop() {
        if($("#s_county").val()=='市、县级市'){
            layer.open({
                title: '信息提醒',
                content: '请选择区域' //这里content是一个普通的String
            });
            return;
        }
        $.post("{:url('set/tpl')}",{county:$("#s_county").val()},function(result){
            if(result==0){
                layer.open({
                    title: '信息提醒',
                    content: '该区域没有店铺' //这里content是一个普通的String
                });
                return;
            }
            $('.shop').append(result);
        });
        return;
    }
    function addgoods() {
        if($("#s_county").val()=='市、县级市'){
            layer.open({
                title: '信息提醒',
                content: '请选择区域' //这里content是一个普通的String
            });
            return;
        }
        $.post("{:url('set/goodstpl')}",{county:$("#s_county").val()},function(result){
            if(result==0){
                layer.open({
                    title: '信息提醒',
                    content: '该区域没有店铺' //这里content是一个普通的String
                });
                return;
            }
            $('.shop').append(result);
        });
        return;
    }

    $(document).on("keyup",'.search',function(){
        var that=$(this);
        $.post("{:url('set/searchshop')}",{key:$(this).val()},function(result){
            that.siblings(".selectshop").html(result);
        });
    });
    //$(document).on("change",'.shop',function(){
        $(document).on("change",'.selectshop',function(){
        var that=$(this);
        var shop_id=$(this).find("option:selected").val();
        $.post("{:url('set/searchgoods')}",{shop_id:shop_id},function(result){
            that.parent().find(".goods").html(result);
        });
    });
    $(".link_btn").click(function(){
        if($("#s_county").val()=='市、县级市'){
            layer.open({
                title: '信息提醒',
                content: '请选择区域' //这里content是一个普通的String
            });
            return;
        }
        if($(".shop").val()=='undefine'){
            layer.open({
                title: '信息提醒',
                content: '没有选择店铺' //这里content是一个普通的String
            });
            return;
        }

        $("#brandForm").submit();

    });
</script>

 </div>
</section>
</body>
</html>
